/**
 * 
 */
package utility.math;

import java.io.Serializable;

/**
 * @author tioz
 *
 */
public class Homotecia implements Transformation, Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8318952522669098051L;
	

	Vector2D o;
	double k;
	
	/**
	 * 
	 */
	public Homotecia(Vector2D o,double c) {
		this.o=o;
		this.k=c;
	}

	/* (non-Javadoc)
	 * @see utility.math.Transformation#applyTo(utility.math.Vector2D)
	 */
	@Override
	public Vector2D applyTo(Vector2D vec) {
		
		Vector2D result= new Vector2D(o);
		Vector2D.minus(vec,o,result);
		Vector2D.time(k,result, result);
		return Vector2D.plus(o, result, result);
	}

	/* (non-Javadoc)
	 * @see utility.math.Transformation#transform(utility.math.Vector2D)
	 */
	@Override
	public void transform(Vector2D vec) {
		vec.thisMinus(o);
		vec.thisTime(k);
		vec.thisPlus(o);
		
	}

}
